Сформируйте матрицу М1 и М2 равной размерности и решите примеры:а) М = 2 * М1 + 5 * (М2 — 3)б) М= 1/2 * (2 * М1 + М2 / 3)- QBasic(Бейсик)

CLS
RANDOMIZE TIMER
ny = 3: nx = 3
DIM m1(ny, nx), m2(ny, nx), ma(ny, nx), mb(ny, nx)
FOR y = 1 TO ny: FOR x = 1 TO nx
        m1(y, x) = FIX(RND * 100)
        m2(y, x) = FIX(RND * 100)
NEXT: NEXT
FOR y = 1 TO ny: FOR x = 1 TO nx
        ma(y, x) = 2 * m1(y, x) + 5 * (m2(y, x) - 3)
        mb(y, x) = 0.5 * (2 * m1(y, x) + (m2(y, x) / 3))
    NEXT
NEXT
PRINT "matrica m1"
FOR y = 1 TO ny: FOR x = 1 TO nx
        PRINT m1(y, x);
NEXT: PRINT: NEXT
PRINT "matrica m2"
FOR y = 1 TO ny: FOR x = 1 TO nx
        PRINT m2(y, x);
NEXT: PRINT: NEXT
PRINT "zadanie a"
FOR y = 1 TO ny: FOR x = 1 TO nx
        PRINT ma(y, x);
NEXT: PRINT: NEXT
PRINT "zadanie b"
FOR y = 1 TO ny: FOR x = 1 TO nx
        PRINT mb(y, x);
NEXT: PRINT: NEXT

Тестирование выполнено в программе QB64 ( Скачать )

Leave a Comment